package com.qdxwx.data.service.approal;

import com.qdxwx.common.page.PageRequest;
import com.qdxwx.data.mapper.approal.ApproalMapper;
import com.qdxwx.models.approal.Approal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class ApproalServiceImpl implements ApproalService {

    @Autowired
    private ApproalMapper approalMapper;

    @Override
    public int insert(Approal approal) {
        approal.setCreateTime(LocalDateTime.now());
        return approalMapper.insertApproal(approal);
    }

    @Override
    public Approal get(int id) {
        if(id < 1) return null;
        return approalMapper.selectById(id);
    }

    @Override
    public List<Approal> getList(Approal approal, PageRequest page) {
        return approalMapper.selectList(approal, page);
    }

    @Override
    public int count(Approal approal) {
        return approalMapper.selectCount(approal);
    }

    @Override
    public int deleteByInfoId(int infoId, int typeId) {
        return approalMapper.deleteByInfoId(infoId, typeId);
    }
}
